Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
jest-haste-map
Advanced tools
The jest-haste-map npm package is a utility for building a Haste map, which is a mapping from module names to file paths. It is used by Jest to quickly resolve module dependencies for tests by keeping an in-memory map of all available modules. It can handle duplicate module names and provides a way to query the map for a specific module.
Building a Haste Map
This code sample demonstrates how to create a new HasteMap instance with a configuration object, build the map, and then use it to get the module name for a specific file.
const HasteMap = require('jest-haste-map');
const config = {
// These options are required:
roots: ['/path/to/project'],
extensions: ['js', 'json'],
platforms: ['ios', 'android'],
// You can provide additional options:
computeSha1: true,
// other options...
};
const hasteMap = new HasteMap(config);
hasteMap.build().then(map => {
console.log(map.hasteFS.getModuleName('/path/to/project/file.js'));
});
Querying the Haste Map
This code sample shows how to query the built Haste map for the path of a module given its name, platform, and whether it supports the native platform.
hasteMap.build().then(map => {
const modulePath = map.moduleMap.getModule('moduleName', 'platform', 'supportsNativePlatform');
console.log(modulePath);
});
Metro is a JavaScript bundler for React Native applications. It includes a Haste map implementation similar to jest-haste-map, but it is tailored specifically for React Native and includes additional features for bundling and transforming code.
Webpack is a powerful module bundler for JavaScript applications. While it does not use a Haste map, it provides a similar functionality through its own resolution mechanism, which can handle complex dependency graphs and offers a wide range of plugins for different tasks.
Browserify is a tool for bundling JavaScript files for usage in the browser. Like webpack, it does not use a Haste map, but it allows developers to require modules in the browser by bundling up all dependencies. It's simpler than webpack and may be more suitable for smaller projects.
26.6.2
[jest-core]
Add findRelatedTests
and nonFlagArgs
in allowed config options for updateConfigAndRun
in watch plugins (#10659)[babel-plugin-jest-hoist]
Preserve order of hoisted mock nodes within containing block (#10536)[babel-plugin-jest-hoist]
Hoist pure constants to support experimental JSX transform in hoisted mocks (#10723)[babel-preset-jest]
Update babel-preset-current-node-syntax
to support top level await (#10747)[expect]
Revert "Fix objectContaining
to work recursively into sub-objects (#10508)" (#10766)[jest-circus, jest-jasmine2]
fix: don't assume stack
is always a string (#10697)[jest-config]
Fix bug introduced in watch mode by PR #10678 (#10692)[jest-config]
Throw correct error for missing preset modules (#10737)[jest-resolve-dependencies]
Resolve mocks as dependencies (#10713)[jest-runtime]
Handle file URLs in dynamic imports (#10744)[jest-runtime, babel-jest]
Pass more ESM options to @jest/transform
(#10752)[jest-runtime]
Properly inject extraGlobals
into the runtime (#10758)[jest-transform]
Link to ESM docs on syntax errors (#10748)[docs]
Add docs for using mocks in TypeScript (#10415)[eslint-config-fb-strict]
Move package from this repo to fbjs
repo (#10739)[examples]
Update TypeScript example to show use of newer Jest types (#10399)[jest-cli]
chore: standardize files and folder names (#10698)[jest-config]
Switch ts-node Register
type to Service
due to deprecation (#11210)FAQs
Unknown package
The npm package jest-haste-map receives a total of 32,211,577 weekly downloads. As such, jest-haste-map popularity was classified as popular.
We found that jest-haste-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.